package com.sskj.lib.bean;

import android.text.TextUtils;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;

public class CoinBean implements Serializable {

    /**
     * code : btc_usdt
     * name : BTC
     * date : 2018-08-23
     * time : 17:54:52
     * price : 6403.4300
     * open : 6673.9800
     * close : 6403.4300
     * high : 6686.8800
     * low : 6250.0000
     * volume : 18464.7247
     * buy : 6402.9400
     * sell : 6403.4300
     * change : -270.5500
     * changeRate : -4.05%
     * cnyPrice :
     * {\code\:\btc_usdt\,\name\:\BTC_USDT\,\date\:\2019-06-20\,\time\:\18:14:44\,\timestamp\:1561025684,\price\:9195.61,\cnyPrice\:9195.61,\open\:9090.39,\close\:9195.61,\high\:9349.95,\low\:8966,\volume\:15911.564683336475,\change\:105.22,\changeRate\:\1.16%\,\buy\:0,\sell\:0}
     */

    private String code;
    private String name;
    private String date;
    private String time;
    private String price;
    private String open;
    private String close;
    private String prevClose;
    private String high;
    private String low;
    private String volume;
    private String buy;
    private String sell;
    private String change;
    private String changeRate;
    private String cnyPrice;
    private boolean light;

    private boolean isSocket = false;

    public boolean isSocket() {
        return isSocket;
    }

    public void setSocket(boolean socket) {
        isSocket = socket;
    }

    public CoinBean(String name, String code) {
        this.name = name;
        this.code = code;
    }


    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    private long timestamp;


    public boolean isUp() {
        try {
            if (Double.valueOf(change) > 0) {
                return true;
            } else {
                return false;
            }
        } catch (Exception e) {
            return false;
        }

    }

    public String getCode() {
        return code == null ? "" : code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name == null ? "" : name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDate() {
        return date == null ? "" : date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getTime() {
        return time == null ? "" : time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getPrice() {
        return price == null ? "0" : price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getOpen() {
        return open == null ? "0" : open;
    }

    public void setOpen(String open) {
        this.open = open;
    }

    public String getClose() {
        return close == null ? "0" : close;
    }

    public void setClose(String close) {
        this.close = close;
    }

    public String getPrevClose() {
        return prevClose == null ? "0" : prevClose;
    }

    public void setPrevClose(String prevClose) {
        this.prevClose = prevClose;
    }

    public String getHigh() {
        return high == null ? "0" : high;
    }

    public void setHigh(String high) {
        this.high = high;
    }

    public String getLow() {
        return low == null ? "0" : low;
    }

    public void setLow(String low) {
        this.low = low;
    }

    public String getVolume() {
        return volume == null ? "0" : volume;
    }

    public void setVolume(String volume) {
        this.volume = volume;
    }

    public String getBuy() {
        return buy == null ? "0" : buy;
    }

    public void setBuy(String buy) {
        this.buy = buy;
    }

    public String getSell() {
        return sell == null ? "0" : sell;
    }

    public void setSell(String sell) {
        this.sell = sell;
    }

    public String getChange() {
        return change == null ? "0" : change.contains("-") ? change : "+" + change;
    }

    public void setChange(String change) {
        this.change = change;
    }

    public String getChangeRate() {
        return changeRate == null ? "" : changeRate.contains("-") ? changeRate : "+" + changeRate;
    }

    public void setChangeRate(String changeRate) {
        this.changeRate = changeRate;
    }

    public String getCnyPrice() {
        return cnyPrice == null ? "0" : cnyPrice;
    }

    public void setCnyPrice(String cnyPrice) {
        this.cnyPrice = cnyPrice;
    }

    public boolean isLight() {
        return light;
    }

    public void setLight(boolean light) {
        this.light = light;
    }
}
